<layout name="layout"/>
<style>
    #ul_pic_list li{margin:5px;list-style-type:none;}
    #old_pic_list li{float:left;width: 150px;height:150px;margin:5px;list-style-type:none;}
    #cat_list{background:#EEE;margin:0;}
    #cat_list li{margin:5px;}
</style>
<div class="main-div">
    <form enctype="multipart/form-data" name="main_form" action="__SELF__" method="post">
        <table cellpadding="3" cellspacing="1" width="100%">
            <tr>
                <td class="label">上级分类：</td>
                <td>
                    <select name="parent_id">
                        <option value="0">顶级分类</option>
                        <?php foreach ($catData as $k => $v):
                            if($v['id'] == $data['id'] || in_array($v['id'],$children))
                                continue;
                            if($v['id'] == $data['parent_id'])
                                $select = 'selected="selected"';
                            else
                                $select = '';
                        ?>
                        <option <?php echo $select; ?> value="<?php echo $v['id']; ?>"><?php echo str_repeat('-', 8*$v['level']) . $v['cat_name']; ?></option>
                        <?php endforeach; ?>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="label">扩展分类：<input onclick="$('#cat_list').append($('#cat_list').find('li').eq(0).clone());" type="button" id="btn_add_cat" value="添加一个" /></td>
                <td>
                    <ul id="cat_list">
                        <?php if($gcData): ?>
                            <?php foreach ($gcData as $k1 => $v1): ?>
                            <li>
                                <select name="ext_cat_id[]">
                                    <option value="">选择分类</option>
                                    <?php foreach($catData as $k =>$v):
                                        if($v['id'] == $v1['cat_id'])
                                            $select = 'selected="selected"';
                                        else
                                            $select ='';
                                    ?>
                                    <option <?php echo $select; ?> value="<?php echo $v['id']; ?>"><?php echo str_repeat('-', 8*$v['level']) . $v['cat_name']; ?></option>
                                    <?php endforeach; ?>
                                </select>
                            </li>
                        <?php endforeach; ?>
                        <?php else: ?>
                        <li>
                            <select name="ext_cat_id[]">
                                <option value="">选择分类</option>
                                <?php foreach($catData as $k =>$v): ?>
                                <option <?php echo $select; ?> value="<?php echo $v['id']; ?>"><?php echo str_repeat('-', 8*$v['level']) . $v['cat_name']; ?></option>
                                <?php endforeach; ?>
                            </select>
                        </li>
                    </ul>
                    <span>如果要删除某个分类请设置为“选择分类”即可！</span>
                </td>
            </tr>
        </table>
    </form>
</div>
